package learn;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by Lenovo
 * DATA:2023/10/28
 * 线程池对象的创建
 **/
public class PoolTest01 {
    public static void main(String[] args) throws InterruptedException {
        //创建线程池对象
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                2,
                3,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(2));//阻塞队列
        //创建任务
        Runnable r=()-> System.out.println(Thread.currentThread().getName());

//        将任务提交给线程池
//        threadPoolExecutor.execute(r);
        for (int i = 0; i < 5; i++) {
            threadPoolExecutor.execute(r);
        }
    }
}
